package com.itheima.controller;

import com.itheima.common.R;
import com.itheima.pojo.Orders;
import com.itheima.service.NewOrderService;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;

/**
 * @author 林晓伟
 */
@RestController
@RequestMapping("/order")
public class NewOrderController {
    @Resource
    private NewOrderService newOrderService;

    /**
     * F16-提交订单
     * @param orders 订单对象
     */
    @PostMapping("/submit")
    public R a(@RequestBody Orders orders){
        Integer a = newOrderService.a(orders);
        if (a != 0){
            return R.success("");
        }
        return R.error("失败");
    }

    /**
     * F16-提交订单
     * @param page 页数
     * @param pageSize 每页条数
     */
    @GetMapping("/userPage")
    public R s(@RequestParam Integer page,
               @RequestParam Integer pageSize){
        return newOrderService.select(page,pageSize);
    }
}
